package com.ku.kill.service;

import com.ku.kill.error.BusinessException;
import com.ku.kill.service.model.ItemModel;

import java.util.List;

/**
 * @program: kill2
 * @description:
 * @author: JokerKu
 * @create: 2020-04-02 22:26
 **/
public interface ItemService {

    //创建商品
    ItemModel createItem(ItemModel itemModel) throws BusinessException;

    //浏览商品列表
    List<ItemModel> listItem();

    //单个商品详情
    ItemModel getItemById(Integer id) throws BusinessException;


    //减库存
    boolean decreaseStock(Integer itemId, Integer amount);

    //todo 库存放入了redis中 从redis里减库存
    boolean decreaseStockInCache(Integer itemId, Integer amount);

    //todo 异步扣减库存
    boolean asyncDecreaseStock(Integer id,Integer amount);

    //todo 如果异步扣减数据库库存消息发送失败，但这时Redis库存已经扣减所以需要补回
    void increaseStock(Integer id,Integer amount);

    //todo 库存流水状态
    String initStockLog(Integer itemId,Integer amount);

    //商品销量增加
    void increaseSales(Integer itemId,Integer amount);


    //从缓存中查询
    ItemModel getItemWithCacheById(Integer id) throws BusinessException;

    //item 及promo model缓存模型
//    ItemModel getItemByIdInCache(Integer id) throws BusinessException;
}
